<?php
/**
 * WAVESELF FRAMEWORK
 * 
 * Waveself framework is an open source project released under New BSD license.
 * Waveself Engine Team did this in order to help you as ourselves with different
 * but still easy to use and learn approach. 
 * 
 * Please read license before you do any changes or to say, before using current software
 * read our licence which can be found under waveself framework root folder.
 * 
 * If you did not recieve copy of licence, contact us immediately and we will send you copy.
 * 
 * @category   Waveself
 * @author     Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright  Waveself Framework NPO 2009-2010
 * @license    https://code.google.com/p/waveself-framework/source/browse/trunk/LICENSE   New-BSD
 * @version    0.1a
 */

/**
 * Current component is base engine startup for complete framework.
 * It's not neccesarry to say anything else. In order to find out more
 * go to docs/index.html (from browser) and navigate yourself to engine section.
 * 
 * @category    Waveself
 * @package     Engine
 * @author      Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright   Waveself Framework NPO 2009-2010
 * @version     1.0b 
 */
class Waveself_Engine extends Waveself_Engine_Abstract
{
	
	/**
	 * For now we need to load basic settings file and call bootstraper.
	 * Pretty much that's all what we need to do inside of Engine.
	 * TODO: Not sure if we need anything else.
	 * 
	 * Abstract class got most of because complete system depends on
	 * @see Waveself_Engine_Abstract
	 */
	public function __construct()
	{
		/** First what we need to do is to load base configurations... */
		if (!isset(self::$_settings['waveself'])) {
			self::$_settings['waveself'] = new Waveself_Settings(
				WAVESELF_SETTINGS_PATH . 'waveself.php'
			);
		}
		
		/** Let's go check engine state */
		$wsettings = $this->getSettings('waveself') -> getRecords();
		
		/** Let's go check engine status and dispatch errors if status matched! */
		switch ($wsettings -> engine -> status) {
			case 0: Waveself_Engine_Errors::offline(); break;
			case 2: Waveself_Engine_Errors::unavailable(); break;
		}
		
		/** Now Let's go load bootstraper **/
		if (!isset(self::$_engineComponents['bootstrap'])) {
			self::$_engineComponents['bootstrap'] = new Waveself_Engine_Bootstrap();
		}
		
	}

}